<?php


class PokaYokeFloat extends PokaYokeRetriever
{
	public function retrieve( $options )
	{
    	if ( $this->value !== "" && floatval( $this->value ) == $this->value && is_float( floatval( $this->value ) ) ) {
			// Minimum comparison
			if ( isset( $options[ 'min' ] ) && $options[ 'min' ] >= $this->value ) {
            	throw new PokaYokeException(
					"Current value [ " . number_format( $this->value, 10 ) . " ] "
					."is lower than minimum value [ " . number_format( $options['min'], 10 ) . " ]"
				);
			}
			
			// Maximum comparison
            if ( isset( $options[ 'max' ] ) && $options[ 'max' ] <= $this->value ) {
            	throw new PokaYokeException(
					"Current value [ " . number_format( $this->value, 10 ) . " ] "
					. "is higher than maximum value [ " . number_format( $options['max'], 10 ) . " ]"
				);
			}

			// Equality comparison
            if ( isset( $options[ 'equals' ] ) && $options[ 'equals' ] != $this->value ) {
            	throw new PokaYokeException(
					"Current value [ " . number_format( $this->value, 10 ) . " ] "
					. "is not equal to value [ " . number_format( $options['equals'], 10 ) . " ]"
				);
			}

			return ( ( float ) $this->value );
    	}

    	throw new PokaYokeException(
			"Cannot filter the value [ type: " . gettype( $this->value ) . " ] into float type"
		);

		return false;
	}
}


?>